<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@ page import="java.util.*,MemberController.ZipcodeBean,Connect.CommonLib" %>

<jsp:useBean id = "zBean" class="MemberController.ZipcodeBean"/>
<jsp:useBean id = "comLib" class="Connect.CommonLib"/>
<HTML>
<HEAD>
<TITLE>郵便番号探し</TITLE>
<SCRIPT LANGUAGE="JavaScript">

<!--

function choiceZipcode( zipcode, address ) {
	
    opener.document.forms['MemJoin'].elements['Mem_Fpost'].value = zipcode.substring(0,4);
    opener.document.forms['MemJoin'].elements['Mem_Spost'].value = zipcode.substring(4,8);
    opener.document.forms['MemJoin'].elements['Mem_Address1'].value = address;
    opener.document.forms['MemJoin'].elements['Mem_Address2'].focus();
    self.close();
}
function goSearch() {
   var flag = document.getElementById("zip_nm").value;
	if ( flag == "" ) {
      alert( '찾으시는 주소의 동(읍/면/리)을 입력하세요.' );
	  document.getElementById("zip_nm").focus();
      return;
  }       
 document.Zip_Search.submit();
}
</SCRIPT>
</HEAD>

<BODY>

<table align="center" width="700" height="150">

	<tr>
		<td>
		<form name="Zip_Search" method="post" action="/KOMORIUTA/MemberLogAction.do?action_code=postcheck">
			<% 
				ArrayList resultList = ( ArrayList )request.getAttribute( "resultList" );
				String town = ( String )request.getAttribute( "town" );
				String find = (String)request.getAttribute("find");
				System.out.println("마을이름:"+town);
				System.out.println(find);
				if ( resultList == null && find == null ) {
			%><br/>
			
			
				<TABLE width="700" height="150" align="center" cellpadding=0 cellspacing=0  background="<%=request.getContextPath() %>/Main/image/Address_Batang.png">
   	 				<TR>
       				 	<TD width="300">
	   					 	<img alt="" src="<%=request.getContextPath() %>/Main/image/Address_Logo.png">
	    				</TD>
	    				
	    				<td valign="middle">
	    					<input type="text" name="zip_nm" id="zip_nm" class="input" maxlength="20" size="30">
	    					<A href="javascript:goSearch();">
	    					<img src="/KOMORIUTA/Main/image/addsearch.gif" border = "0" align = "center"></A>
	    				</td>
	    					
	    				
    				</TR>
				</TABLE>



<%
	} else if( find.equals("2")){
		System.out.println("비교마을이름:"+zBean.getTown());
%>		
<br/>
		
		<TABLE width="700" height="150" align="center" cellpadding=0 cellspacing=0  background="<%=request.getContextPath() %>/Main/image/Address_Batang_2.png">
   	 			<TR>
       				<TD width="300">
	   					 <img alt="" src="<%=request.getContextPath() %>/Main/image/Address_Logo.png">
	    			</TD>
	    				
	    			<td valign="middle">
	    				<input type="text" name="zip_nm" id="zip_nm" class="input" maxlength="20" size="30">
	    				<A href="javascript:goSearch();">
	    				<img src="/KOMORIUTA/Main/image/addsearch.gif" border = "0" align = "center"></A>
	    			</td>
    			</TR>
		</TABLE>


<% } else if( find.equals("1")){
				
				for (int i = 0 ; i < resultList.size() ; i++){

				zBean = (ZipcodeBean)resultList.get(i);
				
				String zipcode = zBean.getZipcode();
					
			 	System.out.println("성공했스므니다");
			
	    	
	    		String address = zBean.getPref() + zBean.getCity() + zBean.getTown()+"&nbsp;";
%>

				<TABLE width="400" border="0" align="center" cellpadding=0 cellspacing=0 class="border">
    				<TR>
        				<TD align="center" class="border">
            				<A HREF="JavaScript:choiceZipcode('<%= zipcode %>','<%= address %>')">
            				[<%= zipcode %>] <%= address %></A><br>
        				</TD>
        			</TR>
        		</TABLE>
        		</form>
<%
				}

}
%>

		</td>
	</tr>
</table>


    






</BODY>

</HTML>